//
//  HWGameCircleFlowLayout.swift
//  PlayWithProject
//
//  Created by 王昌健 on 2021/12/30.
//

import UIKit

class HWGameCircleFlowLayout: UICollectionViewFlowLayout {
    var hasGroup = false
//    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
//        let attrs = super.layoutAttributesForElements(in: rect)
//        if attrs?.count ?? 0 > 0 {
//            let layoutAttributeOne = attrs?[0]
//            var oneFrame = layoutAttributeOne?.frame
//            if hasGroup == true {
//                if layoutAttributeOne?.indexPath.section == 0 {
//                    oneFrame?.origin.x = 0
//                }else {
//                    oneFrame?.origin.x = 76*widthScale
//                }
//            }else {
//                oneFrame?.origin.x = 76*widthScale
//            }
//
//
//            layoutAttributeOne?.frame = oneFrame ?? CGRect.zero
//            for i in 1..<attrs!.count {
//                let currentLayoutAttributes = attrs?[i]
//                let oldLayoutAttributes = attrs?[i-1]
//                if currentLayoutAttributes?.representedElementKind == UICollectionView.elementKindSectionHeader || currentLayoutAttributes?.representedElementKind == UICollectionView.elementKindSectionFooter {
//
//                }else{
//                    if currentLayoutAttributes?.indexPath.row  == 0 {
//                        var frame = currentLayoutAttributes?.frame
//                        frame!.origin.x = 76*widthScale
//                        currentLayoutAttributes?.frame = frame!
//                    }else{
//                        if (currentLayoutAttributes?.indexPath.row ?? 0) % 3 == 0 {
//                            var frame = currentLayoutAttributes?.frame
//                            frame!.origin.x = 76*widthScale
//                            frame!.origin.y = (oldLayoutAttributes?.frame.maxY)! + 14*widthScale
//                            currentLayoutAttributes?.frame = frame!
//                        }else{
//                            var frame = currentLayoutAttributes?.frame
//                            frame!.origin.x = (oldLayoutAttributes?.frame.maxX)! + 14*widthScale
//                            frame!.origin.y = oldLayoutAttributes?.frame.minY ?? 0
//                            currentLayoutAttributes?.frame = frame!
//                        }
//
//                    }
//
//
//                }
//
//            }
        
//        let attrs = super.layoutAttributesForElements(in: rect)
//        if attrs?.count ?? 0 > 0 {
//            let layoutAttributeOne = attrs?[0]
//            var oneFrame = layoutAttributeOne?.frame
//            oneFrame?.origin.x = 15
//            layoutAttributeOne?.frame = oneFrame ?? CGRect.zero
//            for i in 1..<attrs!.count {
//                let currentLayoutAttributes = attrs?[i]
//                let oldLayoutAttributes = attrs?[i-1]
//                if currentLayoutAttributes?.representedElementKind == UICollectionView.elementKindSectionHeader || currentLayoutAttributes?.representedElementKind == UICollectionView.elementKindSectionFooter {
//
//                }else{
//                    if currentLayoutAttributes?.indexPath.row  == 0 {
//                        var frame = currentLayoutAttributes?.frame
//                        frame!.origin.x = 15
//                        currentLayoutAttributes?.frame = frame!
//                    }else{
//                        if (currentLayoutAttributes?.indexPath.row ?? 0) % 3 == 0 {
//                            var frame = currentLayoutAttributes?.frame
//                            frame!.origin.x = 15
//                            frame!.origin.y = (oldLayoutAttributes?.frame.maxY)!+5
//                            currentLayoutAttributes?.frame = frame!
//                        }else{
//                            var frame = currentLayoutAttributes?.frame
//                            frame!.origin.x = (oldLayoutAttributes?.frame.maxX)! + 5
//                            frame!.origin.y = oldLayoutAttributes?.frame.minY ?? 0
//                            currentLayoutAttributes?.frame = frame!
//                        }
//
//                    }
//
//                }
//
//            }
//        }
//
//        return attrs
//    }
    
}
